/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.sql.*;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class stDB {

    static public void DBConnect() {

        try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String url = "jdbc:odbc:st1";
            String user = "sa";
            String password = "";
            conn = DriverManager.getConnection(url, user, password);
            stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
        } catch (Exception e) {
            e.printStackTrace();

        }
    }

    static public void DBClosed() {
        try {
            rs.close();
            stmt.close();
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(stDB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    static public ResultSet DBSqlQuery(String sql) throws SQLException{
        SQL=sql;
        rs=stmt.executeQuery(sql); 
        return rs;
    }
    static public void DBSqlAdd(String sql) throws SQLException{
        SQL=sql;
        boolean r;
        r=stmt.execute(sql); 
        
    }
    static public ResultSet DBReturnRS(){
        return rs;
    }
    static private String SQL;
    static private Connection conn;
    static private Statement stmt;
    static private ResultSet rs;
}

